home *** CD-ROM | disk | FTP | other *** search
/ Network Supervisor's Toolkit / Network Supervisor's Toolkit.iso / tools / lu62 / sendat.c < prev    next >
C/C++ Source or Header  |  1996-07-10  |  8KB  |  255 lines

  1. /*
  2.                          SEND_DATA
  3.  
  4.   Function: This subroutine has deal with "Send_Data" verb.
  5.             In case if resource associated with verb has been right defined
  6.             and conversation is in SEND state verb processing will be
  7.             proceeded.
  8.  
  9.             PS gets records from RM and HS. Actions which will be selected
  10.             depend on received record type. Selected action affects state
  11.             of FSM_ERROR_OR_FAILURE.
  12.  
  13.  Input: pointer to the structure "send_data".
  14.  
  15.  CopyRight 1995. Nicholas Poljakov all rights reserved.
  16.  
  17.  */
  18. #include <stdio.h>
  19. #include <sendat.h>
  20. #include <state1.h>
  21. #include <rcb.h>
  22. #include <tcb.h>
  23. #include <lucb.h>
  24. #include <cma.h>
  25. #include <psp.h>
  26. #include <partner.h>
  27. #include <string.h>
  28.  
  29. #define  no_suspend 200
  30. int sk_r_wt(void *);
  31. int SendBlock(void *, void *);
  32. int setrc(void *, void *);
  33. int sendhsf(void *);
  34. int sendhs(void *);
  35. int sendbm(void *, void *);
  36. int rtsend(void *);
  37. unsigned long rmfmh5(void *, void *);
  38. int recwait(void *);
  39. int rcvru(void *, void *);
  40. int rcvhs(void *, void *, void *, void *);
  41. int ralloc(void *, void *);
  42. int psrm(int, void *, void *);
  43. int ps_conv(int, void *);
  44. int proterr(void *, unsigned long);
  45. int preptrcv(void *, void *);
  46. int post_rcb(void *);
  47. struct repass *postopen(void *);
  48. int phsrec(void *);
  49. int pfmh5(void *);
  50. int opndst(void *);
  51. int obtsess(void *, unsigned char);
  52. int Lrf_handler(void *);
  53. int get_sess(void *, void *);
  54. int get_attr(void *);
  55. int fsm_error(unsigned char, void *);
  56. int fsm_conv(unsigned char, unsigned char, void *);
  57. int flush (void *);
  58. int dcp(void *);
  59. int dealloc(void *);
  60. int crtp(void *);
  61. int conv(void *);
  62. int chkparm(void *, void *);
  63. int check_end(unsigned int, void *);
  64. struct rqb *call_appl(void *);
  65. int buffmng(unsigned char, void *, void *, void *, unsigned, unsigned char, unsigned);
  66. unsigned long attltck(void *);
  67. unsigned long attacheck(void *);
  68. char *cgetmem(int, int);
  69. int sendhsf(void *);
  70. int opndst(void *);
  71. int alloc_rcb(void *, void *);
  72. int allocate(void *);
  73. int clsdst(void *);
  74.  
  75. sendat(pptr)
  76. struct send_data *pptr;
  77. {
  78. extern struct psp psp_ini;
  79. struct rcb *ptr_rcb;
  80. struct tcb *ptr_tcb;
  81. struct lucb *ptr_lucb;
  82. struct pnlu *part;
  83. struct cma ar;
  84. unsigned int type;
  85. char *p;
  86.  
  87. int  fsm_conv();
  88. int  fsm_error();
  89. unsigned short *m;
  90. char s;
  91. char r;
  92. int code;
  93. int state;
  94.  
  95. #if OS_TYPE == 1
  96. /*********  Trace facility **********/
  97. unsigned int rtype;   /* type of record */
  98. unsigned int pnum;    /* point number */
  99. char pname[8];        /* name of module */
  100. char *drec;       /* record for dump */
  101. int  lenr;            /* record length */
  102.  
  103. rtype = INPROC;
  104. strcpy(pname, "sendta");
  105. pnum = 1;
  106. drec = pptr;
  107. lenr = sizeof(struct send_data);
  108. gtf(rtype, pname, pnum, drec, lenr);
  109. /***********************************/
  110. #endif
  111.  
  112.      s = 'S';
  113.      r = 'R';
  114.  
  115.      if (chkparm(pptr, &ar) == -1) {
  116.         return(0);
  117.      }
  118.      ptr_rcb = ar.p_rcb;
  119.      ptr_tcb = ar.p_tcb;
  120. #if OS_TYPE == 1 /* System V */
  121.      pptr -> data_addr = (char *)pptr + sizeof(struct send_data);
  122. #endif
  123.  
  124.      /* Check if the RCB is in wait queue */
  125.      if (sk_r_wt(ptr_rcb) == 0) {
  126.         pptr -> prim_rc = INCOMPLETE;
  127.         return (0);
  128.      }
  129.  
  130.     /*   place verb code into the RCB */
  131.        ptr_rcb -> verb_code = Send_data;
  132.        ptr_rcb -> verb_ptr = pptr;
  133.  
  134.        part = ptr_rcb -> p_partner;
  135.        if (part -> lu_type == 0) {
  136.          SendBlock(pptr, ptr_rcb);
  137.              return 0;
  138.        }
  139.  
  140.        if ((state = fsm_conv(s,Send_data,ptr_rcb)) == -1)
  141.             {
  142.                 pptr -> prim_rc = PORT_ABENDED;
  143.                 return;
  144.             }
  145.        if (state == 1)
  146.             {
  147.                 pptr -> prim_rc = PORT_DISABLED;
  148.                 return;
  149.             }
  150.        else
  151.            {
  152.                switch (ptr_rcb->error_state)   {
  153.  
  154.                  case CONV_FAILURE_PROTOCOL_ERROR:
  155.                       {
  156.                         pptr->prim_rc = RESOURCE_FAILURE_NO_RETRY;
  157.                         fsm_conv(r,RESOURCE_FAILURE_RC,ptr_rcb);
  158.                         break;
  159.                       }
  160.                  case CONV_FAILURE_SON:
  161.                       {
  162.                          pptr->prim_rc=RESOURCE_FAILURE_RETRY;
  163.                          fsm_conv(r,RESOURCE_FAILURE_RC,ptr_rcb);
  164.                          break;
  165.                       }
  166.                  case ALLOCATE_FAILURE_RETRY:
  167.                  case ALLOCATE_FAILURE_NO_RETRY:
  168.                  case SYNC_LEVEL_NOT_SUPPORTED:
  169.                       {
  170.             pptr->prim_rc = ALLOCATION_ERROR;
  171.             if(ptr_rcb->error_state == ALLOCATION_FAILURE_RETRY)
  172.             pptr->sec_rc = ALLOCATION_FAILURE_RETRY;
  173.             if(ptr_rcb->error_state == ALLOCATION_FAILURE_NO_RETRY)
  174.                {
  175.                   pptr->sec_rc = ALLOCATION_FAILURE_NO_RETRY;
  176.                }
  177.             else
  178.                {
  179.                   pptr->sec_rc = SYNC_LEVEL_NOT_SUPPORTED_BY_LU;
  180.                }
  181.             fsm_conv(r,ALLOCATION_ERROR_RC,ptr_rcb);
  182.             break;
  183.          }
  184.                  case RCVD_ERROR:
  185.                       {
  186.              p = &((*ptr_rcb).first_out);
  187.                          type = PREP_TO_RCV_FLUSH;
  188.              buffmng('A', NULL, p, ptr_rcb, 0, 0, type);
  189.                          sendhsf(ptr_rcb);
  190.                       /* pwait(ptr_rcb,ll,0x7FFF); */
  191.              if ((ptr_rcb->error_state == CONV_FAILURE_SON)||
  192.                  (ptr_rcb->error_state == CONV_FAILURE_PROTOCOL_ERROR))
  193.                                {
  194.                   if (ptr_rcb->error_state==CONV_FAILURE_SON)
  195.                  {
  196.                     pptr->prim_rc = RESOURCE_FAILURE_RETRY;
  197.                  }
  198.              else
  199.                  {
  200.                     pptr->prim_rc = RESOURCE_FAILURE_NO_RETRY;
  201.                  }
  202.                   fsm_conv(r,RESOURCE_FAILURE_RC,ptr_rcb);
  203.                                }
  204.                          else
  205.                                {
  206.                                   break;
  207.                                }
  208.                       }
  209.                  case NO_RQS:
  210.                       {
  211.  
  212.        /* Call SEND_DATA_BUFFER_MANAGEMENT */
  213.  
  214.           pptr->prim_rc = OK;
  215.           sendbm(pptr, ptr_rcb);
  216.           if (pptr->prim_rc != OK)
  217.                  return(0); /* SENDBM sets the return code */
  218.  
  219.           if ((ptr_rcb->error_state == ALLOCATION_FAILURE_RETRY)||
  220.               (ptr_rcb->error_state == ALLOCATION_FAILURE_NO_RETRY)||
  221.               (ptr_rcb->error_state == SYNC_LEVEL_NOT_SUPPORTED))
  222.                    {
  223.           /*  Set the return_code to "allocate_error"
  224.            *  and subcode to ether "allocation_return_retry",
  225.            *  allocation_failure_no_retry, or sync_level_not_supported_by_lu
  226.            */
  227.        pptr->prim_rc = ALLOCATION_ERROR;
  228.        if(ptr_rcb->error_state == ALLOCATION_FAILURE_RETRY)
  229.        pptr->sec_rc = ALLOCATION_FAILURE_RETRY;
  230.        if(ptr_rcb->error_state == ALLOCATION_FAILURE_NO_RETRY)
  231.            {
  232.               pptr->sec_rc = ALLOCATION_FAILURE_NO_RETRY;
  233.            }
  234.        else
  235.            {
  236.               pptr->sec_rc = SYNC_LEVEL_NOT_SUPPORTED_BY_LU;
  237.            }
  238.        fsm_conv(r,ALLOCATION_ERROR_RC,ptr_rcb);
  239.   }
  240.        else
  241.            {
  242.      /* Set the return_code to "OK" */
  243.               pptr->prim_rc = OK;
  244.            }
  245.            }
  246.            }
  247.  
  248.      }
  249.          if ( ptr_rcb->rq_to_send_rcvd == YES )
  250.              {
  251.                 pptr->rts = YES;
  252.                 ptr_rcb->rq_to_send_rcvd = No;
  253.              }
  254. }
  255.